package discovery

import (
	"cashcenter/utils/logx"
	"cashcenter/utils/secret"
	"github.com/pkg/errors"
	"github.com/spf13/viper"
	"time"
)

// TODO 配置化
var rpcToken = &secret.Authentication{
	User:     "dlwm-ctp",
	Password: "dlwm-ctp",
}

var EmailDiscover *Explorer

func DiscoverEmail() {
	explorer := NewExplorer(viper.GetStringSlice("etcd.addr"), 3*time.Second)
	if err := explorer.Start("email", rpcToken); err != nil {
		logx.LogrusObj.Fatalln(errors.Wrap(err, "[DISCOVERY]"))
	}

	EmailDiscover = explorer
}
